#include "fxcc/core/BaseImporter.h"
#include "fxcc/core/graph/common/TextureMetaCacheFile.h"

template<>
void fxcc::yml::Serializer::Encode<TextureMetaCache>(YAML::Node& node, const TextureMetaCache& inst)
{
	auto func = [=](const MetaMapIndex& index) {
		return fs::exists(index.m_NativeFile); };

	SetArrayVariable<MetaMapIndex>(node, "m_Texture2Ds", inst.m_Texture2Ds, func);
	SetArrayVariable<MetaMapIndex>(node, "m_Texture2DArrays", inst.m_Texture2DArrays, func);
	SetArrayVariable<MetaMapIndex>(node, "m_TextureCubes", inst.m_TextureCubes, func);
	SetArrayVariable<MetaMapIndex>(node, "m_TextureCubeArrays", inst.m_TextureCubeArrays, func);
	SetArrayVariable<MetaMapIndex>(node, "m_Texture3Ds", inst.m_Texture3Ds, func);
	SetArrayVariable<MetaMapIndex>(node, "m_PrefilterMaps", inst.m_PrefilterMaps, func);
	SetArrayVariable<MetaMapIndex>(node, "m_IrradianceMaps", inst.m_IrradianceMaps, func);
	SetArrayVariable<MetaMapIndex>(node, "m_BRDF_LUT_Maps", inst.m_BRDF_LUT_Maps, func);
}


template<>
bool fxcc::yml::Serializer::Decode<TextureMetaCache>(const YAML::Node& node, TextureMetaCache& inst)
{
	GetArrayVariable<MetaMapIndex>(node, "m_Texture2Ds", inst.m_Texture2Ds);
	GetArrayVariable<MetaMapIndex>(node, "m_Texture2DArrays", inst.m_Texture2DArrays);
	GetArrayVariable<MetaMapIndex>(node, "m_TextureCubes", inst.m_TextureCubes);
	GetArrayVariable<MetaMapIndex>(node, "m_TextureCubeArrays", inst.m_TextureCubeArrays);
	GetArrayVariable<MetaMapIndex>(node, "m_Texture3Ds", inst.m_Texture3Ds);
	GetArrayVariable<MetaMapIndex>(node, "m_PrefilterMaps", inst.m_PrefilterMaps);
	GetArrayVariable<MetaMapIndex>(node, "m_IrradianceMaps", inst.m_IrradianceMaps);
	GetArrayVariable<MetaMapIndex>(node, "m_BRDF_LUT_Maps", inst.m_BRDF_LUT_Maps);
	return true;
}